import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Cache } from "../../../cache/Cache";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { MsgManager } from "../../../manager/MsgManager";
import { UnionInviteInfo } from "../info/UnionInviteInfo";
import { DomWarConst } from "../DomWarConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class UnionInviteCellRender
    
    export  class UnionInviteCellRender extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            var loc1=3;
            this._servNameTxt = ObjCreate.createGTextField("", 11, loc1, 200, 20, this, GlobalStyle.textFormat6);
            this._powerTxt = ObjCreate.createGTextField("", 293, loc1, 150, 20, this, GlobalStyle.textFormat6);
            this._inviteBtn = ObjCreate.createGButton(Language.getString(62051), 425, 0, 40, 25, this);
            this._inviteBtn.drawNow();
            this._inviteBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
            ObjCreate.createBg(0, 27, 510, 2, this, ImagesConst.SplitLine);
            return;
        }

        protected onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.info) 
            {
                if (Cache.instance.country.isDominionPrivilege()) 
                {
                    if (Cache.instance.dominionBea.isInUnion()) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.DomWarInviteServUnion, this.info));
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(90675));
                    }
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(90659));
                }
            }
            return;
        }

        /* internal  */get info(): UnionInviteInfo
        {
            return this._data as UnionInviteInfo;
        }

        public /* override */ set data(arg1: Object)
        {
            if (arg1 == null) 
            {
                return;
            }
            super.data = arg1;
            if (this.info) 
            {
                this._servNameTxt.text = "[" + DomWarConst.getSerNameByDomId(this.info.domId) + "]";
                this._powerTxt.text = this.info.cambat.toString();
            }
            return;
        }

        /* internal */ /* var */_servNameTxt: GTextFiled;

        /* internal */ /* var */_powerTxt: GTextFiled;

        /* internal */ /* var */_inviteBtn: GButton;
    }
